<template>
    <div>
        <p class="resulttitle">{{lotteryname}}开奖结果（最近15期）</p>
        <table class="t_list" border="0" cellpadding="0" cellspacing="1" style="margin-top:1px;font-size: 12px;">
            <tr v-for="(item,index) in resultData" :key="index">
                <td class="t_td_caption_1">{{item.period}}</td>
                <td class="t_td_text">
                    <span v-for="(result,ind) in item.result.balls" :key="ind" style="display:inline-block;">{{result}}<i v-if="result != ''">,</i></span>
                </td>
            </tr>
        </table>
    </div>
</template>
<style scoped>
    .t_td_text>span{
        font-size: 13px;
    }
</style>

<script>

    import axios from 'axios'
    import {lotterytype} from '../../../../assets/js/lotterytype.js'

    export default {
        name: "Gameresult",
        props: {  //普通类型：String、Number、Boolean、Null    引用类型： Array、Object
            refreshState: {  //开奖   刷新
                type: Boolean,
                required: true
            },
            openBet: {  //可下注
                type: Boolean,
                required: true
            },
            ninetime: {  //90s
                type: Number,
                required: true
            },
        },
        data(){
            return{
                resultData: [],  
                lotteryname: '',
            }
        },
        methods: {
            init(){
                // console.log(this.$route.query.id);
                if(this.$route.query.id == 1){
                    this.lotteryname = 'PC蛋蛋';
                }else if(this.$route.query.id == 2){
                    this.lotteryname = '六合彩';
                }else if(this.$route.query.id == 3){
                    this.lotteryname = '北京PK拾';
                }else if(this.$route.query.id == 4){
                    this.lotteryname = '北京快乐8';
                }else if(this.$route.query.id == 5){
                    this.lotteryname = '幸运飞艇';
                }else if(this.$route.query.id == 6){
                    this.lotteryname = '天津时时彩';
                }else if(this.$route.query.id == 7){
                    this.lotteryname = '新疆时时彩';
                }else if(this.$route.query.id == 8){
                    this.lotteryname = '重庆时时彩';
                }else if(this.$route.query.id == 9){
                    this.lotteryname = '安徽快3';
                }else if(this.$route.query.id == 10){
                    this.lotteryname = '江苏快3';
                }else if(this.$route.query.id == 11){
                    this.lotteryname = '山东11选5';
                }else if(this.$route.query.id == 12){
                    this.lotteryname = '广东11选5';
                }else if(this.$route.query.id == 13){
                    this.lotteryname = '江西11选5';
                }else if(this.$route.query.id == 14){
                    this.lotteryname = '广东快乐十分';
                }else if(this.$route.query.id == 15){
                    this.lotteryname = '重庆幸运农场';
                }else if(this.$route.query.id == 16){
                    this.lotteryname = '快3';
                }

                var _this = this;

                this.params = lotterytype.apiParams(this.$route.query.id,this.$route.query.levelid);
                if(window.localStorage.Authorization){
                    
                    _this.$httpGet('/api/game/results/'+ _this.params.nowlottery + '/0').then(response => {
                    
                        if(response.status == 200){
                            _this.resultData = response.data.splice(0,15);  //只要前15条
                        }

                    });
                       
                }
                
            },
            
        },
        mounted(){
            this.init();
        },
        watch: {
            refreshState: function(now,old){
                // console.log('开奖结果',now,old);
                if(now){
                    this.init();
                    this.$emit('refreshed');
                }
                
            },
            openBet: function(now,old){
                // console.log(now,old);
                //开奖  刷新数据
                this.init();
                
            },
            ninetime: function(now,old){
                // console.log(now,old);
                //90s  刷新数据
                this.init();
            },
        },
    }
</script>
